﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Kendo.Mvc.UI;
using ForumBrowser.Models;

namespace ForumBrowser.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetItems([DataSourceRequest] DataSourceRequest request, string id)
        {
            IList<RssItem> items = null;

            if (id != null)
            {
                RssFeed rssFeed = RssReader.Read(string.Format("http://www.kendoui.com/forums/rss.aspx?forumThreadId={0}&rssType=1", id));
                items = rssFeed.Channel.Items;
            }
            else
            {
                items = new List<RssItem>();
            }

            return Json(new DataSourceResult { Data = items });
        }
    }
}
